package com.itheima.goods.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author mySun
 * @create 2021-06-25 19:51
 */
@Configuration
public class MybatisPlusConfig {
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        PaginationInnerInterceptor innerInterceptor = new PaginationInnerInterceptor();
        //设置单页最大数量限制,默认500,-1无限制
        innerInterceptor.setMaxLimit(-1L);
        //        //设置请求的页面大于最大页后操作,true调回到首页，false 继续请求  默认false
        innerInterceptor.setOverflow(true);
        //设置优化左链接的count查询
        innerInterceptor.setOptimizeJoin(true);

        mybatisPlusInterceptor.addInnerInterceptor(innerInterceptor);
        return mybatisPlusInterceptor;
    }
}
